package com.corechina.apex_osswords.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.corechina.apex_osswords.common.Response;
import com.corechina.apex_osswords.common.ShiroUtils;
import com.corechina.apex_osswords.common.WeiXinUserUtils;
import com.corechina.apex_osswords.domain.entity.CoreKnowledgeBaseType;
import com.corechina.apex_osswords.domain.dao.CoreKnowledgeBaseTypeMapper;
import com.corechina.apex_osswords.domain.vo.CoreEquipmentTypeVo;
import com.corechina.apex_osswords.domain.vo.CoreKnowledgeBaseTypeVo;
import com.corechina.apex_osswords.service.ICoreKnowledgeBaseTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 知识库分类表 服务实现类
 * </p>
 *
 * @author fyh
 * @since 2023-02-03
 */
@Service
public class CoreKnowledgeBaseTypeServiceImpl extends ServiceImpl<CoreKnowledgeBaseTypeMapper, CoreKnowledgeBaseType> implements ICoreKnowledgeBaseTypeService {

    @Autowired
    private CoreKnowledgeBaseTypeMapper coreKnowledgeBaseTypeMapper;

    @Override
    public Response getList(String name, Integer pageIndex, Integer pageSize) {
        IPage<CoreKnowledgeBaseTypeVo> knowledgeBaseTypeVoIPage = coreKnowledgeBaseTypeMapper.getList(new Page(pageIndex, pageSize), name, ShiroUtils.getSeeAll().equals(1) ? null : ShiroUtils.getEnterpriseId());
        return Response.ok(knowledgeBaseTypeVoIPage.getRecords(), knowledgeBaseTypeVoIPage.getTotal());
    }

    @Override
    public Response getListForWeiXin(Integer pageIndex, Integer pageSize) {
        IPage<CoreKnowledgeBaseTypeVo> knowledgeBaseTypeVoIPage = coreKnowledgeBaseTypeMapper.getListForWeiXin(new Page(pageIndex, pageSize), WeiXinUserUtils.getEnterpriseId());
        return Response.ok(knowledgeBaseTypeVoIPage.getRecords(), knowledgeBaseTypeVoIPage.getTotal());
    }
}

